spectrum_routines Module


Uses


Functions

public pure function compute_overlap_segment_count(n, winsize) result(rst)

Computes the number of overlapped signals using a nominal 50% overlap.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: n

The total length of the signal being overlapped.

integer(kind=int32), intent(in) :: winsize

The window size.

Return Value integer(kind=int32)

The number of segments.

public pure function compute_transform_length(n) result(rst)

Computes the length of the positive half of a discrete Fourier transform for a specific signal length.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: n

The signal length (length of the signal put forth to the Fourier transform).

Return Value integer(kind=int32)

The length of the positive half of the discrete Fourier transform.

public pure function cumulative_sum(x) result(rst)

Computes the cumulative sum of an array.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x(:)

The N-element array on which to operate.

Return Value real(kind=real64), allocatable, (:)

An N-element array containing the cumulative sum of each element in x (e.g. cumulative_sum(x) = [x(1), x(1) + x(2), ...]).

public pure function difference(x) result(rst)

Computes the difference between each element in an array.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x(:)

The N-element array on which to operate.

Return Value real(kind=real64), allocatable, (:)

The N-1 element array containing the difference between each element in x.

public pure elemental function frequency_bin_width(fs, n) result(rst)

Computes the bin width for a discrete frequency spectrum based upon the data sample rate.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: fs

The rate at which the signal was sampled. The units of this value will be the units of the output.

integer(kind=int32), intent(in) :: n

The signal length (length of the signal put forth to the Fourier transform).

Return Value real(kind=real64)

The frequency bin width.

public pure elemental function is_power_of_two(n) result(rst)

Tests to see if a value is an integer power of two.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: n

The value to test.

Return Value logical

Returns true if n is a power of two; else, false.

public pure elemental function next_power_of_two(n) result(rst)

Provides the next higher integer power of two.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: n

The value to test.

Return Value integer(kind=int32)

The next power of two higher than n. If n is already a power of two, its value is simply returned. For instance, if n is set to 128, then a value of 7 is returned ( ).

public pure function remove_mean(x) result(rst)

Removes the mean offset from the specified data set.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

The array on which to operate.

Return Value real(kind=real64), allocatable, dimension(:)

The data set with its mean removed.

public pure function unpack_real_transform(x, fac) result(rst)

Unpacks a real-valued transform into its complex-valued format.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x(:)

The complex-valued signal stored in a real-valued array. This array is assumed to be of length N.

real(kind=real64), intent(in), optional :: fac

An optional scaling input. The default is 1 such that no scaling is performed.

Return Value complex(kind=real64), allocatable, dimension(:)

The unpacked complex-valued form of the input array.


Subroutines

public pure subroutine overlap(x, seg, winsize, buffer)

Extracts a segment from a signal allowing for a nominally 50% overlap.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x(:)

An N-element array containing the entire signal.

integer(kind=int32), intent(in) :: seg

The one-based index of the segment to extract.

integer(kind=int32), intent(in) :: winsize

The size of the window (segment). If this value is less than N, the end of the segment will be padded with zeros.

real(kind=real64), intent(out) :: buffer(:)

A winsize array where the segment will be written.

public subroutine unwrap(x, tol)

Shifts phase angle arrays to deal with jumps greater than or equal to tol by adding multiples of until the jump is less than tol.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(inout) :: x(:)

On input, the phase array. On output, the unwrapped phase array.

real(kind=real64), intent(in), optional :: tol

The tolerance value.